package com.dou.sample.baserecycleradapter;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    RecyclerView mRecycler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mRecycler = findViewById(R.id.recycler);

        List<String> data = new ArrayList<>();
        data.add("111");
        data.add("222");
        data.add("333");
        mRecycler.setLayoutManager(new LinearLayoutManager(this));
        mRecycler.setAdapter(new CommenAdapter<String>(this, R.layout.item_base_recycler, data) {
            @Override
            public void convert(ViewHolder holder, String s) {
                TextView tv = holder.findView(R.id.text_center);
                tv.setText(s);
            }
        });
    }
}
